package com.lwy.setter.types;


import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

public class StringOption implements Serializable {
    /**
     * 选项值
     */
    private String value;

    /**
     * 选项名称
     */
    private String label;

    /**
     * 是否可用, 默认为false
     */
    private Boolean disabled;

    /**
     * 展示顺序，默认9999
     */
    private Integer sequence;

    public StringOption() {
    }

    private StringOption(String value, String label, Boolean disabled, Integer sequence) {
        if (StringUtils.isAnyBlank(value, label)) {
            throw new IllegalArgumentException("value or label can not be empty.");
        }
        this.value = value;
        this.label = label;
        this.disabled = disabled != null && disabled;
        this.sequence = sequence == null ? 9999 : sequence;
    }

    public static StringOption of(String value, String label, Boolean disabled, Integer sequence) {
        return new StringOption(value, label, disabled, sequence);
    }

    public static StringOption of(String value, String label) {
        return new StringOption(value, label, null, null);
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public Boolean getDisabled() {
        return disabled;
    }

    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    public Integer getSequence() {
        return sequence;
    }

    public void setSequence(Integer sequence) {
        this.sequence = sequence;
    }
}
